package com.zp.self.module.level_5_设计模式.创建型模式.Ⅱ_工厂方法.工厂方法;

import lombok.Setter;
import org.junit.Test;

/**
 * @author ：by Zeng Peng
 * @date ：Created 2022/6/25 9:53
 * @description ：咖啡店业务类
 */
public class CoffeeStore {
    @Setter
    private CoffeeFactory coffeeFactory;

    public Coffee orderCoffee(){
        return coffeeFactory.createCoffee();
    }

    @Test
    public void orderCoffeeTest(){
        CoffeeStore store = new CoffeeStore();
        store.setCoffeeFactory(new LatteCoffeeFactory());
        Coffee coffee_01 = store.orderCoffee();
        System.out.println(coffee_01.getName());
        System.out.println("----------分割线---------------");

        store.setCoffeeFactory(new AmericanCoffeeFactory());
        Coffee coffee_02 = store.orderCoffee();
        System.out.println(coffee_02.getName());
        System.out.println("----------分割线---------------");

        Coffee coffee_03 = store.orderCoffee();
        System.out.println(coffee_03.getName());
    }
}
